package com.googlecode.flealancemarket.tapestry.pages;

import com.googlecode.flealancemarket.core.tapestry.SpringBean;
import com.googlecode.flealancemarket.metamodel.Category;
import com.googlecode.flealancemarket.metamodel.CategoryGroup;
import com.googlecode.flealancemarket.service.commands.BrowseCategories;
import java.util.List;
import org.apache.tapestry.ioc.annotations.Inject;
import com.googlecode.flealancemarket.tapestry.util.Session;
import org.apache.tapestry.annotations.ApplicationState;

public class Categories {

    @ApplicationState
    private Session session;

    @Inject
    @SpringBean("com.googlecode.flealancemarket.service.commands.BrowseCategories")
    private BrowseCategories categoryBrowser;

    private List<CategoryGroup> categoryGroups;
    private List<Category> categories;
    private CategoryGroup ctgGroup;
    private Category ctg;

    public long getUserId(){
        return session.getUserId();
    }

    public List<CategoryGroup> getCategoryGroups(){
        return (List<CategoryGroup>)categoryBrowser.execute();
    }

    public CategoryGroup getCtgGroup() {
        return ctgGroup;
    }

    public void setCtgGroup(CategoryGroup ctgGroup) {
        this.ctgGroup = ctgGroup;
    }

    public Category getCtg() {
        return ctg;
    }

    public void setCtg(Category ctg) {
        this.ctg = ctg;
    }
    /*
    Object onActivate(){
        session.setUserId(55);
        session.setUsername("Vanja");
        return null;
    }
     * 
     */
}
